const fs=require('fs')
const path=require('path')
const dbpath=path.join(__dirname,'../','publl','db','user.json')
const adduser=async(params)=>{
  const {username,password,age,nickname}=params
  const data=JSON.parse(fs.readFileSync(dbpath,'utf-8'))
  let addData={
    id:new Date().getTime(),
    username,password,nickname,age,
  }
  data.push(addData);
  fs.writeFileSync(dbpath,JSON.stringify(data),'utf-8');
  return true;
}

module.exports={
    adduser
}